home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / QuickDraw GX / QuickDraw GX Info / QuickDraw GX Interfaces / Interfaces & Libraries / Pascal Interfaces & Libraries / Pascal Interfaces / LoaderRoutines.p < prev    next >
Encoding:
Text File  |  1994-04-02  |  4.6 KB  |  123 lines  |  [TEXT/MPS ]

  1. {
  2.  segment loader:
  3.     public interface definition
  4.     by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
  5.     Copyright 1987 - 1991 Apple Computer, Inc.  All rights reserved.    
  6. }
  7.  
  8. {$IFC UNDEFINED UsingIncludes}
  9. {$SETC UsingIncludes := 0}
  10. {$ENDC}
  11.  
  12. {$IFC NOT UsingIncludes}
  13.     UNIT LoaderRoutines;
  14.     INTERFACE
  15. {$ENDC}
  16.  
  17. {$IFC UNDEFINED UsingLoaderRoutines}
  18. {$SETC UsingLoaderRoutines := 1}
  19.  
  20.  
  21. {$I+}
  22. {$SETC LoaderRoutinesIncludes := UsingIncludes}
  23. {$SETC UsingIncludes := 1}
  24. {$IFC UNDEFINED UsingMemoryTypes}
  25. {$I $$Shell(PInterfaces)MemoryTypes.p}
  26. {$ENDC}
  27. {$SETC UsingIncludes := LoaderRoutinesIncludes}
  28.  
  29. CONST
  30. returnSegmentSize = 1;
  31. returnSegmentData = 2;
  32. returnSegmentCount = 3;
  33. returnTaskReturnStack = 4;
  34.  
  35.  
  36. TYPE
  37. SegmentSpoolType = LongInt;
  38. SegmentSpoolTypePointer = ^SegmentSpoolType;
  39. SegmentSpoolTypeArray = ARRAY [0..0] OF SegmentSpoolType;
  40.  
  41.  
  42. SegmentSpoolFunction = ProcPtr;
  43. SegmentSpoolFunctionPointer = ^SegmentSpoolFunction;
  44. SegmentSpoolFunctionArray = ARRAY [0..0] OF SegmentSpoolFunction;
  45.  
  46.  
  47.  
  48. {$IFC UNDEFINED VoidDefined}
  49. {$SETC VoidDefined := 1}
  50. VOID = RECORD END;
  51. {$ENDC}
  52.  
  53. LoaderClient = ^Void;
  54. LoaderClientPointer = ^LoaderClient;
  55. LoaderClientArray = ARRAY [0..0] OF LoaderClient;
  56.  
  57. PROCEDURE InitializeLoader; C;
  58.  
  59. { these routines allocate and dispose of loader clients }
  60. FUNCTION NewLoaderClient(memoryStart: Ptr; memoryLength: LongInt; spoolFunc: SegmentSpoolFunction; userReference: LongInt): LoaderClient; C;
  61. PROCEDURE DisposeLoaderClient(client: LoaderClient); C;
  62.  
  63. { these routines return the non-modifiable fields of a loaderClient }
  64. FUNCTION GetLoaderClientGlobals(client: LoaderClient): Ptr; C;
  65. FUNCTION GetLoaderClientGlobalsStart(client: LoaderClient): Ptr; C;
  66. FUNCTION GetLoaderClientHeap(client: LoaderClient): GxHeapPointer; C;
  67.  
  68. { these routines get and set the modifiable fields of a loaderClient }
  69. FUNCTION GetLoaderClientUserReference(client: LoaderClient): LongInt; C;
  70. PROCEDURE SetLoaderClientUserReference(client: LoaderClient; newRef: LongInt); C;
  71. FUNCTION GetLoaderClientSpoolFunction(client: LoaderClient): SegmentSpoolFunction; C;
  72. PROCEDURE SetLoaderClientSpoolFunction(client: LoaderClient; newFunc: SegmentSpoolFunction); C;
  73.  
  74. { these must be switched at process switch time if several processes are using the loaderClient }
  75. FUNCTION GetLoaderClientReturnStack(client: LoaderClient): Ptr; C;
  76. PROCEDURE SetLoaderClientReturnStack(client: LoaderClient; newStack: Ptr); C;
  77. FUNCTION GetLoaderClientLastBlock(client: LoaderClient): Ptr; C;
  78. PROCEDURE SetLoaderClientLastBlock(client: LoaderClient; lastBlock: Ptr); C;
  79.  
  80. { this routine disposes of all the unlocked segments in the loaderClient’s code gxHeap }
  81. PROCEDURE FlushLoaderSegments(client: LoaderClient); C;
  82.  
  83. {
  84.  this routine loads the segment that contains the function pointed to by address, locks this segment down and makes
  85.     it permanent by patching the jump table to jump straight into it. this segment can never be moved or disposed of after
  86.     this, since the segment loader no longer has any way of knowing whether some process is currenly executing in it or
  87.     not 
  88. }
  89.  
  90. PROCEDURE LoadPermanentSegment(address: Ptr); C;
  91.  
  92. {
  93.  this routine aborts all the functions entered in the return stack from its current position back to the passed saveStack
  94.     value. the lockCounts for all these functions will be updated properly and the returnStack and lastBlock will be restored 
  95. }
  96.  
  97. PROCEDURE CleanupLoaderReturnStack(client: LoaderClient; savedStack: Ptr); C;
  98.  
  99. { these routines lock and unlock access to the loader client’s code gxHeap. the first one also sets the busy counts for code blocks correctly }
  100. PROCEDURE LockLoaderClientMemory(client: LoaderClient); C;
  101. PROCEDURE UnlockLoaderClientMemory(client: LoaderClient); C;
  102.  
  103. { this routine validates the passed loaderClient to ensure that it is a loaderClient and it hasn’t been damaged }
  104. PROCEDURE ValidateLoaderClient(client: LoaderClient); C;
  105.  
  106. { this returns the size of the patchRecord that Patch and Unpatch LoaderClientFunction use }
  107. FUNCTION GetLoaderClientPatchSize: LongInt; C;
  108.  
  109. { you must call these routines to create and destroy patch records for jump table entries }
  110. FUNCTION PatchLoaderClientFunction(client: LoaderClient; functionA5Offset: Integer; patchAddress: Ptr): Ptr; C;
  111. PROCEDURE UnpatchLoaderClientFunction(client: LoaderClient; patchAddress: Ptr); C;
  112.  
  113. { once the patch record has been created, these functions allow jump table entries to be redirected }
  114. FUNCTION GetLoaderClientFunction(client: LoaderClient; functionA5Offset: Integer): Ptr; C;
  115. PROCEDURE SetLoaderClientFunction(client: LoaderClient; functionA5Offset: Integer; newAddress: Ptr); C;
  116.  
  117.  
  118. {$ENDC}
  119.  
  120. {$IFC NOT UsingIncludes}
  121.     END.
  122. {$ENDC}
  123.